package com.jy.wms.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jy.wms.common.annotions.BaseServiceDescribe;
import com.jy.wms.common.base.BaseService;
import com.jy.wms.common.base.ServiceException;
import com.jy.wms.dao.WmsSoCustomDetailedMapper;
import com.jy.wms.pojo.WmsSoCustomDetailed;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @ClassName: WmsSoCustomDetailedService.java
* @Description: TODO(这里用一句话描述这个类的作用)
* @Author Jane
* @Date Fri Dec 29 17:12:17 CST 2017
*/

@Service
public class WmsSoCustomDetailedService extends BaseService<WmsSoCustomDetailedMapper,WmsSoCustomDetailed> {

 /**
 * 插入一条记录
 * @param entity 实体对象
 * @return int
 */
 @BaseServiceDescribe(moduleName = "新增采购订单附加表明细信息",btnName = "新增采购订单附加表明细信息")
public void baseInsert( WmsSoCustomDetailed entity)throws ServiceException {
    Integer count=dao.countBySsfydmxId(entity.getSsfydmxid());
    if(count==0){
        Integer success=dao.baseInsertSelective( entity );
        if(success<=0){
            throw new ServiceException("新增采购订单附加表明细信息失败");
        }
    }else{
        throw new ServiceException("此发运订单明细已加入数据，如需改动请编辑");
    }
}

/**
* 插入一条记录（匹配有值的字段）
* @param entity 实体对象
* @return int
*/
public Integer baseInsertSelective(WmsSoCustomDetailed entity){
     return dao.baseInsertSelective( entity);
}

/**
* 删除（根据主键ID删除）
* @param id 主键
* @return int
*/
public Integer baseDeleteByPrimaryKey(String id){
     return dao.baseDeleteByPrimaryKey( id);
}

/**
* 删除（根据ID 批量删除）
* @param idList 主键ID列表
* @return int
*/
public Integer baseDeleteBathPrimaryKeys(List<String> idList){
     return dao.baseDeleteBathPrimaryKeys( idList );
}

/**
* 分页查询
* @param entity 实体
* @return Page<WmsSoCustomDetailed>
*/
public Page<WmsSoCustomDetailed> baseSelectPage(WmsSoCustomDetailed entity ){
    PageHelper.startPage(entity.getPage(),entity.getRows());
    return (Page<WmsSoCustomDetailed>)dao.baseSelectPage( entity );
}

/**
* 查询（根据主键ID查询）
* @param ssfydmxid 所属发运单明细Id
* @return WmsSoCustomDetailed
*/
public WmsSoCustomDetailed baseSelectByPrimaryKey(String ssfydmxid ){
     return dao.baseSelectByPrimaryKey( ssfydmxid );
}
    /**
     * 查询（根据主键ID查询）
     * @param sssocid 所属发运单附加表Id
     * @return WmsSoCustomDetailed
     */
    public List<WmsSoCustomDetailed> wmsSoCustomDetailedBySsfydId(String sssocid ){
        return dao.wmsSoCustomDetailedBySsfydId( sssocid );
    }
/**
* 查询（根据ID 批量查询）
* @param idList 主键ID列表
* @return list
*/
public Integer baseSelectBathPrimaryKeys(List<WmsSoCustomDetailed> idList ){
     return dao.baseSelectBathPrimaryKeys( idList );
}

/**
*修改 （匹配有值的字段）
* @param entity 主键ID列表
* @return int
*/
@BaseServiceDescribe(moduleName = "编辑采购订单附加表明细信息",btnName = "编辑采购订单附加表明细信息")
public void baseUpdateByPrimaryKeySelective( WmsSoCustomDetailed entity)throws ServiceException {
   Integer success=dao.baseUpdateByPrimaryKeySelective( entity);
   if(success<=0){
       throw new ServiceException("编辑采购订单附加表明细信息失败");
   }
}

/**
*修改（根据主键ID修改）
* @param entity 主键ID列表
* @return int
*/
public Integer baseUpdateByPrimaryKey(WmsSoCustomDetailed entity){
     return dao.baseUpdateByPrimaryKey( entity);
}
}
